﻿#if UNITY
using System;
using UnityEngine;

namespace com.susi.util
{
    public class ColliderAndTriggerReturner : MonoBehaviour
    {
        public event Action<GameObject> OnExit;
        public event Action<GameObject> OnEnter;
        public event Action<GameObject> OnStay;
        private void OnCollisionEnter(Collision collision)
        {
            OnEnter?.Invoke(collision.gameObject);
        }
        private void OnCollisionEnter2D(Collision2D collision)
        {
            OnEnter?.Invoke(collision.gameObject);
        }
        private void OnCollisionExit(Collision collision)
        {
            OnExit?.Invoke(collision.gameObject);
        }
        private void OnCollisionExit2D(Collision2D collision)
        {
            OnExit?.Invoke(gameObject);
        }
        private void OnCollisionStay(Collision collision)
        {
            OnStay?.Invoke(gameObject);
        }
        private void OnCollisionStay2D(Collision2D collision)
        {
            OnStay?.Invoke(collision.gameObject);
        }
        private void OnParticleCollision(GameObject other)
        {
            OnEnter?.Invoke(other);
        }
        private void OnTriggerEnter(Collider other)
        {
            OnEnter(other.gameObject);
        }
        private void OnTriggerEnter2D(Collider2D collision)
        {
            OnEnter?.Invoke(collision.gameObject);
        }
        private void OnTriggerExit(Collider other)
        {
            OnExit?.Invoke(other.gameObject);
        }

        private void OnTriggerExit2D(Collider2D collision)
        {
            OnExit?.Invoke(collision.gameObject);
        }

        private void OnTriggerStay(Collider other)
        {
            OnStay?.Invoke(other.gameObject);
        }
        private void OnParticleTrigger()
        {
            OnStay?.Invoke(null);
        }
        private void OnTriggerStay2D(Collider2D collision)
        {
            OnStay?.Invoke(collision.gameObject);
        }
    }
}
#endif